package cn.sdormitory.controller.wechat;

import cn.sdormitory.common.api.CommonPage;
import cn.sdormitory.common.api.CommonResult;
import cn.sdormitory.wx.req.WechatPushMessageReq;
import cn.sdormitory.wx.service.WechatPushMessageService;
import cn.sdormitory.wx.vo.WechatPushMessageVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author : yy
 * @date: 2024/9/29 15:32
 * @description:
 */
@Api(tags = "微信公众号消息推送")
@RestController
@RequestMapping("/wechat/push")
public class WechatPushMessageController {
    @Resource
    WechatPushMessageService wechatPushMessageService;


    @ApiOperation("查询微信公众号消息推送列表")
    @PostMapping(value = "/listPushMessage")
    public CommonResult<CommonPage<WechatPushMessageVO>> listPushMessage(@RequestBody WechatPushMessageReq wechatPushMessageReq) {
        IPage<WechatPushMessageVO> page = wechatPushMessageService.listPushMessage(wechatPushMessageReq);
        return CommonResult.success(CommonPage.restPage(page));
    }

    @ApiOperation("删除指定推送消息")
    @DeleteMapping(value = "/delPushMessage/{ids}")
    public CommonResult delPushMessage(@PathVariable Long[] ids) {
        wechatPushMessageService.deleteByIds(ids);
        return CommonResult.success();
    }
}
